Reworking of Marcus’ code

Note that EQ subscales were not part of the original scale, but are based on Lawrence et al., 2004.

Dependencies

library(readr)
library(dplyr)
library(tidyr)
library(correlation)
library(see)
library(insight)

Anonymise data

Run only the first time, before data sharing

Load data

data_raw <- read.csv("../data/raw/data_raw.csv") 

Rename and select

data_trimmed <- data_raw %>% 
  rename(
    # rename "Q" to PET, rename attention checks items
    PET_1 = Q2,
    PET_2 = Q4,
    PET_3 = Q6,
    PET_4 = Q8,
    PET_5 = Q10,
    PET_6 = Q12,
    PET_7 = Q14,
    attention_check_1 = IRI_24,
    # Because of the attention check item, all IRI_items after 24 have to be renamed  
    IRI_24 = IRI_25,
    IRI_25 = IRI_26,
    IRI_26 = IRI_27,
    IRI_27 = IRI_28,
    IRI_28 = IRI_29,
    attention_check_2 = EQ_60,
    # Because of the attention check item, EQ Item 61 has to be renamed
    EQ_60 = EQ_61,
    PTTA_1 = PTT.A_test1,
    PTTA_2 = PTT.A_test2,
    PTTA_3 = PTT.A_test3,
    PTTA_4 = PTT.A_test4,
    PTTA_5 = PTT.A_test5,
    PTTA_6 = PTT.A_test6,
    PTTA_7 = PTT.A_test7,
    PTTA_8 = PTT.A_test8,
    PTTA_9 = PTT.A_test9,
    PTTA_10 = PTT.A_test10,
    PTTA_11 = PTT.A_test11,
    PTTA_12 = PTT.A_test12,
    PTTA_13 = PTT.A_test13,
    PTTA_14 = PTT.A_test14,
    PTTA_15 = PTT.A_test15,
    PTTA_16 = PTT.A_test16,
    PTTA_17 = PTT.A_test17,
    PTTA_18 = PTT.A_test18,
    PTTA_19 = PTT.A_test19,
    PTTA_20 = PTT.A_test20,
    PTTA_21 = PTT.A_test21,
    PTTA_22 = PTT.A_test22,
    PTTA_23 = PTT.A_test23,
    PTTA_24 = PTT.A_test24,
    PTTA_25 = PTT.A_test25,
    PTTA_26 = PTT.A_test26,
    PTTA_27 = PTT.A_test27,
    PTTA_28 = PTT.A_test28,
    PTTA_29 = PTT.A_test29,
    PTTA_30 = PTT.A_test30,
    PTTA_31 = PTT.A_test31,
    PTTA_32 = PTT.A_test32
  ) |>
  # wrangle gender
  mutate(gender = ifelse(Gender == "self-identified:", Gender_3_TEXT, Gender)) |>
  # select variables of interest
  select(unique_id,
         timepoint,
         age = Age_1, 
         gender,
         attention_check_1,
         attention_check_2,
         SITES,
         starts_with("IRI_"), 
         starts_with("EQ_"),
         starts_with("PET_"),
         starts_with("EYES_"),
         starts_with("PTP_"),
         starts_with("PTTA_")) |>
  # drop meta data columns
  select(!ends_with(".Click") & !ends_with(".Submit") & !ends_with(".Count")) |>
  # drop filler and sample items
  select(!all_of(c("EYES_0", 
                   "EQ_2", "EQ_3", "EQ_5", "EQ_7", "EQ_9", "EQ_13", "EQ_16", "EQ_17", "EQ_20", "EQ_23", 
                   "EQ_24", 
                   # "EQ_30", # is not used in the total score, but is used in the social skills subscale
                   # "EQ_31", # is not used in the total score, but is used in the social skills subscale
                   # "EQ_33", # is not used in the total score, but is used in the social skills subscale
                   "EQ_40", "EQ_45", "EQ_47", 
                   # "EQ_51", # is not used in the total score, but is used in the social skills subscale
                   # "EQ_53", # is not used in the total score, but is used in the social skills subscale
                   "EQ_56"))) 

Convert all responses to numeric

data_recoded <- data_trimmed |>
  # age
  mutate(age = as.numeric(age)) |>
  
  # attention checks
  mutate(attention_check_1 = ifelse(attention_check_1 == "C", "passed", "failed"),
         attention_check_2 = ifelse(attention_check_2 == "strongly agree", "passed", "failed")) |>
  
  # SITES
  mutate(SITES = recode(SITES,
                          '1 Not very true of me' = 1,
                          '2' = 2,
                          '3' = 3,
                          '4' = 4,
                          '5 Very true of me.' = 5)) |>
  
  # IRI
  mutate(across(
    all_of(c("IRI_1", "IRI_2", "IRI_5", "IRI_6", "IRI_8", "IRI_9", "IRI_10", "IRI_11", "IRI_16", "IRI_17", 
             "IRI_20", "IRI_21", "IRI_22", "IRI_23", "IRI_24", "IRI_25", "IRI_26", "IRI_27", "IRI_28")),
    ~ recode(.x,
             'A - DOES NOT DESCRIBE ME VERY WELL' = 0,
             'B' = 1,
             'C' = 2,
             'D' = 3,
             'E - DESCRIBES ME VERY WELL' = 4)
  )) |>
  mutate(across(
    all_of(c("IRI_3", "IRI_4", "IRI_7", "IRI_12", "IRI_13", "IRI_14", "IRI_15", "IRI_18", "IRI_19")),
    ~ recode(.x,
             'A - DOES NOT DESCRIBE ME VERY WELL' = 4,
             'B' = 3,
             'C' = 2,
             'D' = 1,
             'E - DESCRIBES ME VERY WELL' = 0)
  )) |>
  
  # # EQ
  # mutate(across(
  #   all_of(c("EQ_1", "EQ_6", "EQ_19", "EQ_22", "EQ_25", "EQ_26", "EQ_35", "EQ_36", "EQ_37", "EQ_38", 
  #            "EQ_41", "EQ_42", "EQ_43", "EQ_44", "EQ_52", "EQ_54", "EQ_55", "EQ_57", "EQ_58", "EQ_59", "EQ_60")),
  #   ~ recode(.x,
  #            'strongly agree' = 2,
  #            'slightly agree' = 1,
  #            'slightly disagree' = 0,
  #            'strongly disagree' = 0)
  # )) |>
  # mutate(across(
  #   all_of(c("EQ_4", "EQ_8", "EQ_10", "EQ_11", "EQ_12", "EQ_14", "EQ_15", "EQ_18", "EQ_21", "EQ_27", "EQ_28", 
  #            "EQ_29", "EQ_32", "EQ_34", "EQ_39", "EQ_46", "EQ_48", "EQ_49", "EQ_50")),
  #   ~ recode(.x,
  #            'strongly agree' = 2,
  #            'slightly agree' = 1,
  #            'slightly disagree' = 0,
  #            'strongly disagree' = 0)
  # )) |> 
  
  # EQ
  mutate(across(
    all_of(c("EQ_1", "EQ_6", "EQ_19", "EQ_22", "EQ_25", "EQ_26", "EQ_35", "EQ_36", "EQ_37", "EQ_38", 
             "EQ_41", "EQ_42", "EQ_43", "EQ_44", "EQ_52", "EQ_54", "EQ_55", "EQ_57", "EQ_58", "EQ_59", 
             "EQ_60", "EQ_33", "EQ_51", "EQ_53")),   # <-- added EQ_33, EQ_51, EQ_53
    ~ recode(.x,
             'strongly agree' = 2,
             'slightly agree' = 1,
             'slightly disagree' = 0,
             'strongly disagree' = 0)
  )) |>
  mutate(across(
    all_of(c("EQ_4", "EQ_8", "EQ_10", "EQ_11", "EQ_12", "EQ_14", "EQ_15", "EQ_18", "EQ_21", "EQ_27", "EQ_28", 
             "EQ_29", "EQ_30", "EQ_31", "EQ_32", "EQ_34", "EQ_39", "EQ_46", "EQ_48", "EQ_49", "EQ_50")),   # <-- added EQ_30, EQ_31
    ~ recode(.x,
             'strongly agree' = 0,
             'slightly agree' = 0,
             'slightly disagree' = 1,
             'strongly disagree' = 2)
  )) |>
  
  # PET
  mutate(across(
    starts_with("PET_"),
    ~ recode(.x,
             'not at all' = 1,
             'a little bit' = 2,
             'it arouses some feelings' = 3,
             'quite a lot' = 4,
             'very much' = 5)
  )) |>
  
  # EYES
  mutate(EYES_1  = recode(EYES_1,  'playful' = 1, .default = 0), 
         EYES_2  = recode(EYES_2,  'upset' = 1, .default = 0), 
         EYES_3  = recode(EYES_3,  'desire' = 1, .default = 0), 
         EYES_4  = recode(EYES_4,  'insisting' = 1, .default = 0), 
         EYES_5  = recode(EYES_5,  'worried' = 1, .default = 0), 
         EYES_6  = recode(EYES_6,  'fantasizing' = 1, .default = 0), 
         EYES_7  = recode(EYES_7,  'uneasy' = 1, .default = 0), 
         EYES_8  = recode(EYES_8,  'despondent' = 1, .default = 0), 
         EYES_9  = recode(EYES_9,  'preoccupied' = 1, .default = 0), 
         EYES_10 = recode(EYES_10, 'cautious' = 1, .default = 0), 
         EYES_11 = recode(EYES_11, 'regretful' = 1, .default = 0), 
         EYES_12 = recode(EYES_12, 'sceptical' = 1, .default = 0), 
         EYES_13 = recode(EYES_13, 'anticipating' = 1, .default = 0), 
         EYES_14 = recode(EYES_14, 'accusing' = 1, .default = 0), 
         EYES_15 = recode(EYES_15, 'contemplative' = 1, .default = 0), 
         EYES_16 = recode(EYES_16, 'thoughtful' = 1, .default = 0), 
         EYES_17 = recode(EYES_17, 'doubtful' = 1, .default = 0), 
         EYES_18 = recode(EYES_18, 'decisive' = 1, .default = 0), 
         EYES_19 = recode(EYES_19, 'tentative' = 1, .default = 0), 
         EYES_20 = recode(EYES_20, 'friendly' = 1, .default = 0), 
         EYES_21 = recode(EYES_21, 'fantasizing' = 1, .default = 0), 
         EYES_22 = recode(EYES_22, 'preoccupied' = 1, .default = 0), 
         EYES_23 = recode(EYES_23, 'defiant' = 1, .default = 0), 
         EYES_24 = recode(EYES_24, 'pensive' = 1, .default = 0), 
         EYES_25 = recode(EYES_25, 'interested' = 1, .default = 0), 
         EYES_26 = recode(EYES_26, 'hostile' = 1, .default = 0), 
         EYES_27 = recode(EYES_27, 'cautious' = 1, .default = 0), 
         EYES_28 = recode(EYES_28, 'interested' = 1, .default = 0), 
         EYES_29 = recode(EYES_29, 'reflective' = 1, .default = 0), 
         EYES_30 = recode(EYES_30, 'flirtatious' = 1, .default = 0), 
         EYES_31 = recode(EYES_31, 'confident' = 1, .default = 0), 
         EYES_32 = recode(EYES_32, 'serious' = 1, .default = 0), 
         EYES_33 = recode(EYES_33, 'concerned' = 1, .default = 0), 
         EYES_34 = recode(EYES_34, 'distrustful' = 1, .default = 0), 
         EYES_35 = recode(EYES_35, 'nervous' = 1, .default = 0), 
         EYES_36 = recode(EYES_36, 'suspicious' = 1, .default = 0)) |>
  
  # McHugh Perspective Taking Protocol
  mutate(PTP_1 = recode(PTP_1, 'Red Lego brick' = 1, .default = 0),
         PTP_2 = recode(PTP_2, 'Black chair' = 1, .default = 0),
         PTP_3 = recode(PTP_3, 'Watching television' = 1, .default = 0),
         PTP_4 = recode(PTP_4, 'Green Lego brick' = 1, .default = 0),
         PTP_5 = recode(PTP_5, 'Blue chair' = 1, .default = 0),
         PTP_6 = recode(PTP_6, 'Reading' = 1, .default = 0),
         #PTP_7 = recode(PTP_7, 'Black chair' = 1, .default = 0), # this item was incorrectly implemented in the survey as a single reversed trial not a double
         PTP_7 = recode(PTP_7, 'Blue chair' = 1, .default = 0),
         PTP_8 = recode(PTP_8, 'Black chair' = 1, .default = 0),
         PTP_9 = recode(PTP_9, 'Watching television' = 1, .default = 0)) |>
  
  # Perspective Taking Task for Adults (PTT-A) - ALL 'CORRECT' RESPONSES NEED CHECKING AGAINST JAMIE'S CODE
  mutate(PTTA_1 = recode(PTTA_1, 'Picture 6' = 1, .default = 0),
         PTTA_2 = recode(PTTA_2, 'Picture 4' = 1, .default = 0),
         PTTA_3 = recode(PTTA_3, 'Picture 1' = 1, .default = 0),
         PTTA_4 = recode(PTTA_4, 'Picture 8' = 1, .default = 0),
         PTTA_5 = recode(PTTA_5, 'Picture 3' = 1, .default = 0),
         PTTA_6 = recode(PTTA_6, 'Picture 2' = 1, .default = 0),
         PTTA_7 = recode(PTTA_7, 'Picture 7' = 1, .default = 0),
         PTTA_8 = recode(PTTA_8, 'Picture 3' = 1, .default = 0),
         PTTA_9 = recode(PTTA_9, 'Picture 1' = 1, .default = 0),
         PTTA_10 = recode(PTTA_10, 'Picture 2' = 1, .default = 0),
         PTTA_11 = recode(PTTA_11, 'Picture 7' = 1, .default = 0),
         PTTA_12 = recode(PTTA_12, 'Picture 8' = 1, .default = 0),
         PTTA_13 = recode(PTTA_13, 'Picture 5' = 1, .default = 0),
         PTTA_14 = recode(PTTA_14, 'Picture 6' = 1, .default = 0),
         PTTA_15 = recode(PTTA_15, 'Picture 4' = 1, .default = 0),
         PTTA_16 = recode(PTTA_16, 'Picture 3' = 1, .default = 0),
         PTTA_17 = recode(PTTA_17, 'Picture 3' = 1, .default = 0),
         PTTA_18 = recode(PTTA_18, 'Picture 6' = 1, .default = 0),
         PTTA_19 = recode(PTTA_19, 'Picture 5' = 1, .default = 0),
         PTTA_20 = recode(PTTA_20, 'Picture 2' = 1, .default = 0),
         PTTA_21 = recode(PTTA_21, 'Picture 8' = 1, .default = 0),
         PTTA_22 = recode(PTTA_22, 'Picture 1' = 1, .default = 0),
         PTTA_23 = recode(PTTA_23, 'Picture 4' = 1, .default = 0),
         PTTA_24 = recode(PTTA_24, 'Picture 7' = 1, .default = 0),
         PTTA_25 = recode(PTTA_25, 'Picture 4' = 1, .default = 0),
         PTTA_26 = recode(PTTA_26, 'Picture 5' = 1, .default = 0),
         PTTA_27 = recode(PTTA_27, 'Picture 1' = 1, .default = 0), # ??
         PTTA_28 = recode(PTTA_28, 'Picture 2' = 1, .default = 0), # ??
         PTTA_29 = recode(PTTA_29, 'Picture 4' = 1, .default = 0), # ??
         PTTA_30 = recode(PTTA_30, 'Picture 8' = 1, .default = 0), # ??
         PTTA_31 = recode(PTTA_31, 'Picture 6' = 1, .default = 0), # ??
         PTTA_32 = recode(PTTA_32, 'Picture 5' = 1, .default = 0)) # ??

# checks
table(data_trimmed$SITES, data_recoded$SITES)
##                        
##                           1   2   3   4   5
##   1 Not very true of me   1   0   0   0   0
##   2                       0   8   0   0   0
##   3                       0   0  29   0   0
##   4                       0   0   0 113   0
##   5 Very true of me.      0   0   0   0  86
table(data_trimmed$IRI_20, data_recoded$IRI_20)
##                                     
##                                       0  1  2  3  4
##                                       0  0  0  0  0
##   A - DOES NOT DESCRIBE ME VERY WELL  8  0  0  0  0
##   B                                   0 15  0  0  0
##   C                                   0  0 47  0  0
##   D                                   0  0  0 99  0
##   E - DESCRIBES ME VERY WELL          0  0  0  0 67
table(data_trimmed$IRI_4, data_recoded$IRI_4)
##                                     
##                                       0  1  2  3  4
##                                       0  0  0  0  0
##   A - DOES NOT DESCRIBE ME VERY WELL  0  0  0  0 74
##   B                                   0  0  0 74  0
##   C                                   0  0 55  0  0
##   D                                   0 25  0  0  0
##   E - DESCRIBES ME VERY WELL          8  0  0  0  0
table(data_trimmed$EQ_1, data_recoded$EQ_1)
##                    
##                       0   1   2
##                       0   0   0
##   slightly agree      0 104   0
##   slightly disagree  19   0   0
##   strongly agree      0   0 106
##   strongly disagree   6   0   0
table(data_trimmed$EQ_50, data_recoded$EQ_50)
##                    
##                       0   1   2
##                       0   0   0
##   slightly agree     39   0   0
##   slightly disagree   0 110   0
##   strongly agree     23   0   0
##   strongly disagree   0   0  63
table(data_trimmed$PET_6, data_recoded$PET_6)
##                           
##                              1   2   3   4   5
##                              0   0   0   0   0
##   a little bit               0  19   0   0   0
##   it arouses some feelings   0   0  19   0   0
##   not at all                 4   0   0   0   0
##   quite a lot                0   0   0  57   0
##   very much                  0   0   0   0 136
table(data_trimmed$EYES_27, data_recoded$EYES_27)
##             
##                0   1
##                2   0
##   arrogant    25   0
##   cautious     0 168
##   joking       6   0
##   reassuring  36   0
table(data_trimmed$PTP_5, data_recoded$PTP_5)
##              
##                 0   1
##                 2   0
##   Black chair  47   0
##   Blue chair    0 188
table(data_trimmed$PTTA_4, data_recoded$PTTA_4)
##            
##               0   1
##               5   0
##   Picture 1  13   0
##   Picture 2   2   0
##   Picture 3   3   0
##   Picture 4   9   0
##   Picture 5   1   0
##   Picture 6   6   0
##   Picture 7   7   0
##   Picture 8   0 191

Calculate total scores

data_processed <- data_recoded |>
  # SITES
  mutate(SITES_completeness = ifelse(!is.na(SITES), "complete", "partial")) |>
  
  # IRI
  mutate(IRI_completeness = ifelse(rowSums(across(starts_with("IRI_"), ~ !is.na(.x))) == 28, "complete", "partial"),
         IRI_FS = IRI_1 + IRI_5 + IRI_7 + IRI_12 + IRI_16 + IRI_26 + IRI_23,
         IRI_EC = IRI_2 + IRI_4 + IRI_9 + IRI_14 + IRI_18 + IRI_20 + IRI_22,
         IRI_PT = IRI_3 + IRI_8 + IRI_11 + IRI_15 + IRI_21 + IRI_25 + IRI_28,
         IRI_PD = IRI_6 + IRI_10 + IRI_13 + IRI_17 + IRI_19 + IRI_24 + IRI_27,
         IRI_total = IRI_FS + IRI_EC + IRI_PT + IRI_PD) |>
  # EQ
  mutate(EQ_completeness = ifelse(rowSums(across(starts_with("EQ_"), ~ !is.na(.x))) == 45, "complete", "partial"),
         EQ_total = EQ_1 + EQ_4 + EQ_6 + EQ_8 + EQ_10 + EQ_11 + EQ_12 + EQ_14 + EQ_15 + EQ_18 + EQ_19 + EQ_21 + EQ_22 + EQ_25 + 
           EQ_26 + EQ_27 +  EQ_28 + EQ_29 + EQ_32 + EQ_34 + EQ_35 + EQ_36 + EQ_37 + EQ_38 + EQ_39 + EQ_41 + EQ_42 + EQ_43 + EQ_44 + 
           EQ_46 + EQ_48 + EQ_49 + EQ_50 + EQ_52 + EQ_54 + EQ_55  + EQ_57 + EQ_58 + EQ_59 + EQ_60,
         EQ_cog = EQ_8 + EQ_19 + EQ_22 + EQ_25 + EQ_26 + EQ_35 + EQ_36 + EQ_41 + EQ_43 + EQ_44 + EQ_52 + EQ_54 + EQ_55 + EQ_58 + EQ_60,
         EQ_aff = EQ_1 + EQ_6 + EQ_18 + EQ_21 + EQ_32 + EQ_38 + EQ_39 + EQ_42 + EQ_46 + EQ_48 + EQ_50 + EQ_59,
         EQ_soc = EQ_14 + EQ_29 + EQ_30 + EQ_31 + EQ_33 + EQ_34 + EQ_51 + EQ_53) |>
  
  # PET - the mean score is calculated
  mutate(PET_completeness = ifelse(rowSums(across(starts_with("PET_"), ~ !is.na(.x))) == 7, "complete", "partial"),
         PET_total = (PET_1 + PET_2 + PET_3 + PET_4 + PET_5 + PET_6 + PET_7)/7) |>
  
  # EYES
  mutate(EYES_completeness = ifelse(rowSums(across(starts_with("EYES_"), ~ !is.na(.x))) == 36, "complete", "partial"),
         EYES_total = EYES_1 + EYES_2 + EYES_3 + EYES_4 + EYES_5 + EYES_6 + EYES_7 + EYES_8 + EYES_9 + EYES_10 + 
           EYES_11 + EYES_12 + EYES_13 + EYES_14 + EYES_15 + EYES_16 + EYES_17 + EYES_18 + EYES_19 + EYES_20 + 
           EYES_21 + EYES_22 + EYES_23 + EYES_24 + EYES_25 + EYES_26 + EYES_27 + EYES_28 + EYES_29 + EYES_30 + 
           EYES_31 + EYES_32 + EYES_33 + EYES_34 + EYES_35 + EYES_36) |>
  
  # # PTP
  # mutate(PTP_completeness = ifelse(rowSums(across(starts_with("PTP_"), ~ !is.na(.x))) == 9, "complete", "partial"),
  #        PTP_simple = PTP_1 + PTP_2 + PTP_3,
  #        PTP_reversed = PTP_4 + PTP_5 + PTP_6,
  #        PTP_doublereversed = PTP_7 + PTP_8 + PTP_9,
  #        PTP_total = PTP_1 + PTP_2 + PTP_3 + PTP_4 + PTP_5 + PTP_6 + PTP_7 + PTP_8 + PTP_9) |>
  
  # PTP
  mutate(PTP_completeness = ifelse(rowSums(across(starts_with("PTP_"), ~ !is.na(.x))) == 9, "complete", "partial"),
         PTP_simple = PTP_1 + PTP_2 + PTP_3,
         PTP_reversed = PTP_4 + PTP_5 + PTP_6 + PTP_7, # PTP_7 was incorrectly implemented as a single reversed trial instead of double. corrected here.
         PTP_doublereversed = PTP_8 + PTP_9, # PTP_7 was incorrectly implemented as a single reversed trial instead of double. corrected here.
         PTP_total = PTP_1 + PTP_2 + PTP_3 + PTP_4 + PTP_5 + PTP_6 + PTP_7 + PTP_8 + PTP_9) |>
  
  # PTT-A
  # note: no completeness check as it is a timed test where not all items are answered
  mutate(PTTA_total = PTTA_1 + PTTA_2 + PTTA_3 + PTTA_4 + PTTA_5 + PTTA_6 + PTTA_7 + PTTA_8 + PTTA_9 + PTTA_10 + PTTA_11 + PTTA_12 + PTTA_13 + PTTA_14 + PTTA_15 + PTTA_16 + PTTA_17 + PTTA_18 + PTTA_19 + PTTA_20 + PTTA_21 + PTTA_22 + PTTA_23 + PTTA_24 + PTTA_25 + PTTA_26 + PTTA_27 + PTTA_28 + PTTA_29 + PTTA_30 + PTTA_31 + PTTA_32) |>
  
  # master exclude
  mutate(exclude_master = ifelse(attention_check_1 == "passed" & 
                                   attention_check_2 == "passed" & 
                                   SITES_completeness == "complete" &
                                   IRI_completeness == "complete" &
                                   EQ_completeness == "complete" &
                                   PET_completeness == "complete" &
                                   EYES_completeness == "complete" &
                                   PTP_completeness == "complete",
                                 "include",
                                 "exclude")) |>
  
  # reorder
  select(unique_id, 
         timepoint, 
         age, gender, 
         
         # exclusion variables
         exclude_master, attention_check_1, attention_check_2, SITES_completeness, IRI_completeness, EQ_completeness, PET_completeness, EYES_completeness, PTP_completeness,
         
         # (sub)scale scores
         SITES, IRI_FS, IRI_EC, IRI_PT, IRI_PD, IRI_total, EQ_total, EQ_cog, EQ_aff, EQ_soc, PET_total, EYES_total, PTP_simple, PTP_reversed, PTP_doublereversed, PTP_total, PTTA_total,
         
         # item level scores
         IRI_1, IRI_2, IRI_3, IRI_4, IRI_5, IRI_6, IRI_7, IRI_8, IRI_9, IRI_10, IRI_11, IRI_12, IRI_13, IRI_14, IRI_15, 
         IRI_16, IRI_17, IRI_18, IRI_19, IRI_20, IRI_21, IRI_22, IRI_23, IRI_24, IRI_25, IRI_26, IRI_27, IRI_28, 
         
         EQ_1, EQ_4, EQ_6, EQ_8, EQ_10, EQ_11, EQ_12, EQ_14, EQ_15, EQ_18, EQ_19, EQ_21, EQ_22, EQ_25, EQ_26, EQ_27, 
         EQ_28, EQ_29, EQ_32, EQ_34, EQ_35, EQ_36, EQ_37, EQ_38, EQ_39, EQ_41, EQ_42, EQ_43, EQ_44, EQ_46, EQ_48, EQ_49, 
         EQ_50, EQ_52, EQ_54, EQ_55, EQ_57, EQ_58, EQ_59, EQ_60, 
         
         PET_1, PET_2, PET_3, PET_4, PET_5, PET_6, PET_7, 
         
         EYES_1, EYES_2, EYES_3, EYES_4, EYES_5, EYES_6, EYES_7, EYES_8, EYES_9, EYES_10, EYES_11, EYES_12, EYES_13, EYES_14, 
         EYES_15, EYES_16, EYES_17, EYES_18, EYES_19, EYES_20, EYES_21, EYES_22, EYES_23, EYES_24, EYES_25, EYES_26, EYES_27, 
         EYES_28, EYES_29, EYES_30, EYES_31, EYES_32, EYES_33, EYES_34, EYES_35, EYES_36,
         
         PTP_1, PTP_2, PTP_3, PTP_4, PTP_5, PTP_6, PTP_7, PTP_8, PTP_9,
         
         PTTA_1, PTTA_2, PTTA_3, PTTA_4, PTTA_5, PTTA_6, PTTA_7, PTTA_8, 
         PTTA_9, PTTA_10, PTTA_11, PTTA_12, PTTA_13, PTTA_14, PTTA_15, PTTA_16, 
         PTTA_17, PTTA_18, PTTA_19, PTTA_20, PTTA_21, PTTA_22, PTTA_23, PTTA_24, 
         PTTA_25, PTTA_26, PTTA_27, PTTA_28, PTTA_29, PTTA_30, PTTA_31, PTTA_32)

Sanity checks - item correlations

dat <- data_processed |>
  filter(timepoint == 1 & exclude_master == "include")

dat |>
  select(starts_with("IRI")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

dat |>
  select(starts_with("EQ")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

dat |>
  select(starts_with("PET")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

dat |>
  select(starts_with("EYES")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

dat |>
  select(starts_with("PTP")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

dat |>
  select(starts_with("PTTA")) |>
  correlation() |>
  summary() |>
  plot(show_data = "points")

Write to disk

write_csv(data_processed, "../data/processed/data_processed.csv") 

Session info

sessionInfo()
## R version 4.3.3 (2024-02-29)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS 15.4
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Europe/Zurich
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] insight_0.19.10   see_0.8.3         correlation_0.8.4 tidyr_1.3.1      
## [5] dplyr_1.1.4       readr_2.1.5      
## 
## loaded via a namespace (and not attached):
##  [1] sandwich_3.1-1     sass_0.4.9         generics_0.1.3     lattice_0.22-6    
##  [5] hms_1.1.3          digest_0.6.37      magrittr_2.0.3     evaluate_1.0.1    
##  [9] grid_4.3.3         estimability_1.5.1 mvtnorm_1.3-3      fastmap_1.2.0     
## [13] Matrix_1.6-5       jsonlite_1.8.9     survival_3.5-8     multcomp_1.4-28   
## [17] purrr_1.0.4        scales_1.3.0       TH.data_1.1-3      codetools_0.2-20  
## [21] jquerylib_0.1.4    cli_3.6.4          crayon_1.5.3       rlang_1.1.6       
## [25] bit64_4.6.0-1      munsell_0.5.1      splines_4.3.3      withr_3.0.2       
## [29] cachem_1.1.0       yaml_2.3.10        parallel_4.3.3     tools_4.3.3       
## [33] datawizard_0.10.0  tzdb_0.5.0         coda_0.19-4.1      colorspace_2.1-1  
## [37] ggplot2_3.5.2      bayestestR_0.13.2  vctrs_0.6.5        R6_2.6.1          
## [41] zoo_1.8-14         lifecycle_1.0.4    emmeans_1.10.2     bit_4.6.0         
## [45] vroom_1.6.5        MASS_7.3-60.0.1    pkgconfig_2.0.3    pillar_1.10.2     
## [49] bslib_0.8.0        gtable_0.3.6       glue_1.8.0         xfun_0.49         
## [53] tibble_3.2.1       tidyselect_1.2.1   rstudioapi_0.17.1  parameters_0.21.6 
## [57] knitr_1.49         farver_2.1.2       xtable_1.8-4       htmltools_0.5.8.1 
## [61] labeling_0.4.3     rmarkdown_2.29     compiler_4.3.3